package com.wuhao.code.check.model

import com.aegis.mybatis.xmlless.annotations.JsonMappingProperty
import com.aegis.mybatis.xmlless.model.base.BaseSimpleClassWrapper
import com.aegis.mybatis.xmlless.resolver.ParameterResolver
import com.wuhao.code.check.hasAnnotation
import org.jetbrains.kotlin.psi.KtClass

/**
 * @author 吴昊
 * @date 2024/01/19
 * @version 1.0
 * @since v4.0.0
 */
class SimpleKtClassWrapper(private val ktClass: KtClass) : BaseSimpleClassWrapper {

  override fun getJavaClass(): Class<*> {
    return Any::class.java
  }

  override fun isComplex(): Boolean {
    val allInterfaces = ktClass.getAllSuperClassNames()
    val fullName = ktClass.fqName?.toString()!!
    return !ktClass.isPrimitive()
        && !ktClass.hasAnnotation(JsonMappingProperty::class.java)
        && fullName != "kotlin.Array"
        && !ktClass.isEnum()
        && !ParameterResolver.isNotComplexType(fullName, allInterfaces)
  }

  override fun isBoolean(): Boolean {
    return ktClass.name == "Boolean"
  }

  override fun isString(): Boolean {
    return ktClass.name == "String"
  }

}
